//
//  CustomTableViewCell.m
//  10--CustomTableViewCell
//
//  Created by 冀永金 on 16/7/27.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "NewsObject.h"
@interface CustomTableViewCell ()

@end
@implementation CustomTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
// 自定义TabelViewcell的初始化方法
//initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //NSLog(@"%@",NSStringFromCGRect(self.frame));
        [self config];
    }
    return self;
}
- (void)config {
    // 初始化方法中， 只负责创建
    self.image = [[UIImageView alloc]init];
    [self.contentView addSubview:self.image];
    self.label1 = [[UILabel alloc]init];
    [self.contentView addSubview:self.label1];
    //_label1.text = @"小岳岳   我的天呐！";
    _label1.backgroundColor = [UIColor redColor];
    self.label2 = [[UILabel alloc]init];
    [self.contentView addSubview:self.label2];
    _label2.backgroundColor = [UIColor yellowColor];
    self.label3 = [[UILabel alloc]init];
    [self.contentView addSubview:self.label3];
    _label3.backgroundColor = [UIColor cyanColor];

}


// 给子视图布局
- (void)layoutSubviews {
    [super layoutSubviews];
    self.image.frame = CGRectMake(10, 10, 80, 80);
    self.label1.frame = CGRectMake(100, 10, 250, 30);
    self.label2.frame = CGRectMake(100, 50, 200, 30);
    _label3.frame = CGRectMake(310,60, 80, 30);
}

- (void)setObject:(NewsObject *)object {
    _image.image = [UIImage imageNamed:object.newsImage];
    _label1.text = object.NewsTitle;
    _label2.text = object.newsDescription;
    _label3.text = object.newsNumberCount;
    
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
